<div id="attendancemodel" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&chi;</button>
    <h3 id="myModalLabel">My Attendance for <?= date('d-M-Y')?></h3>
  </div>
  <div class="modal-body">
    <p>
     <input type="hidden" value="<?= $server_time?>" id="server_time" />  
   
    <table width="100%" class="table">
  <tr>
    <td width="30%">
	<div class="" style="display:none; " id="show_entry_time"></div>
    <input type="button" value="Entry Time" name="attendance_entry" id="attendance_entry" class="btn btn-primary " />
   </td>
   <td width="30%">Show Time</td>
    <td width="30%">
	<input type="button" value="Exit Time" name="attendance_exit" id="attendance_exit" class="btn btn-danger span1" />
    <div class="" style="display:none; font-weight:bold" id="show_exit_time"></div>
    </td>
    <td><!--<strong>Total Working Hours</strong> :<span id="stopwatch">00:00:00</span>--></td>
  </tr>
</table>
<table style="margin-top: 30px">
	<tr>
	<td><h5>What youre gonna drink today ?</h5></td>
	<td style="width: 80px;"><div class="" style="display:none; " id="show_drinks"></div></td>
	<td style="width: 100px;"><input type="radio" name="drink" class="drink" value="tea" checked/>&nbsp;<img src="<?= $this->config->base_url(); ?>assets/images/tea.png" ></td>
	<td style="width: 100px;"><input type="radio" name="drink" class="drink" value="coffee"/>&nbsp;<img src="<?= $this->config->base_url(); ?>assets/images/coffee.png" ></td>
	<td style="width: 100px;"><input type="radio" name="drink" class="drink" value="soup"/>&nbsp;<img src="<?= $this->config->base_url(); ?>assets/images/soup.png" ></td>
	</tr>
</table>
	<div class="modal-footer">
			<input type="button" class="btn btn-success" value="Order" name="drinks" id="drinks"/>
					</div>
   </p>
  </div>
  
</div>
<script type="text/javascript" >
	$(document).ready(function() {			
$.post('<?= site_url('user/attendance/check_entry_time');?>', function(data){	
	  if(data){
	  	$('#attendance_entry').hide()		
		$('#show_entry_time').show()
		$('#show_entry_time').html("Entry Time :"+data)		
	  }else {
		$('#attendance_exit').hide()  
	  }
});	

$.post('<?= site_url('user/attendance/check_exit_time');?>', function(data){
	
	  if(data){	 
		$('#attendance_exit').hide()		
		$('#show_exit_time').show()
		$('#show_exit_time').html("Exit Time :"+data)				
	  }	
	  else {
		//$('#attendance_exit').hide()  
	  }
});	


});

// Entry time for attendance
$("#attendance_entry").click(function(){			
var server_time = $("#server_time").val();
 var count = 0;
//alert(server_time)
 $.post('<?= site_url('user/attendance/insert_entry_time');?>',{time : server_time}, function(data) {
	 alert(data)	 
	 $('#myModal').modal('hide')
	 $('#attendance_entry').hide()	
	 $('#show_entry_time').show()	
location.reload();
	 
});
})

// exit time for attendance
$("#attendance_exit").click(function(){			
var server_time = $("#server_time").val();
//alert(server_time)

 $.post('<?= site_url('user/attendance/insert_exit_time');?>',{time : server_time}, function(data) {	 
	 if(data){
		alert(data)
		 $.post('<?= site_url('user/attendance/insert_daily_attendance_sheet');?>', function(msg) { 
		 alert(msg)		
		if(msg)
		{
	 $('#myModal').modal('hide')
	 $('#attendance_exit').hide()	
	 location.reload();
	}
		 }); 	 
	 	 }
	 
});
})


$("#drinks").click(function(){	

var drink = $(".drink:checked").val();

			

$.post('<?= site_url('user/attendance/check_id');?>', function(data){	
	  if(data){
 		var id = data;
		$.post('<?= site_url('user/drinks/insert_drinks');?>',{id : id,drink : drink}, function() {	 
	 		alert("Your" + " " + drink + " " + "is gonna be ready for today !");

				$('.drink').hide()		
					$('#show_drinks').show()
						$('#show_drinks').html("It's "+drink)
							$('#myModal').modal('hide')
	 								
		});			
	  }	
	 
});
})

</script>